﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true"
  CodeBehind="ProductCategory.aspx.cs" Inherits="SaleManagement.Web.Pages.ProductCategory" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dxhf" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <table width="100%">
    <tr>
      <td class="search_header">
        Danh mục nhóm hàng hóa
      </td>
    </tr>
  </table>
  <div>
    <dxwgv:ASPxGridView ID="gvProductGroup" ClientInstanceName="gvProductGroup" runat="server"
      CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" OnCustomCallback="gvProductGroup_CustomCallback"
      OnCustomJSProperties="gvProductGroup_CustomJSProperties" OnPageIndexChanged="gvProductGroup_PageIndexChanged"
      AutoGenerateColumns="False" Width="50%">
      <SettingsBehavior AllowDragDrop="False" AllowGroup="False" AllowSort="False" />
      <Styles CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua">
      </Styles>
      <SettingsLoadingPanel Text="" />
      <SettingsPager>
        <AllButton>
          <Image Height="19px" Width="28px" />
        </AllButton>
        <FirstPageButton>
          <Image Height="19px" Width="23px" />
        </FirstPageButton>
        <LastPageButton>
          <Image Height="19px" Width="23px" />
        </LastPageButton>
        <NextPageButton>
          <Image Height="19px" Width="19px" />
        </NextPageButton>
        <PrevPageButton>
          <Image Height="19px" Width="19px" />
        </PrevPageButton>
      </SettingsPager>
      <Images ImageFolder="~/App_Themes/Aqua/{0}/">
        <CollapsedButton Height="15px" Width="13px" Url="~/App_Themes/Aqua/GridView/gvCollapsedButton.png" />
        <ExpandedButton Height="15px" Width="13px" Url="~/App_Themes/Aqua/GridView/gvExpandedButton.png" />
        <DetailCollapsedButton Height="15px" Width="13px" Url="~/App_Themes/Aqua/GridView/gvDetailCollapsedButton.png" />
        <DetailExpandedButton Height="15px" Width="13px" Url="~/App_Themes/Aqua/GridView/gvDetailExpandedButton.png" />
        <HeaderFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilter.png" Width="19px" />
        <HeaderActiveFilter Height="19px" Url="~/App_Themes/Aqua/GridView/gvHeaderFilterActive.png"
          Width="19px" />
        <HeaderSortDown Height="5px" Width="6px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortDown.png" />
        <HeaderSortUp Height="5px" Width="6px" Url="~/App_Themes/Aqua/GridView/gvHeaderSortUp.png" />
        <FilterRowButton Height="13px" Width="13px" />
        <CustomizationWindowClose Width="18px" />
        <PopupEditFormWindowClose Width="18px" />
        <WindowResizer Height="13px" Width="12px" Url="~/App_Themes/Aqua/GridView/WindowResizer.png" />
        <FilterBuilderClose Width="18px" />
      </Images>
      <StylesEditors>
        <ProgressBar Height="25px">
        </ProgressBar>
      </StylesEditors>
      <ImagesEditors>
        <CalendarPrevYear Width="23px" />
        <CalendarPrevMonth Width="19px" />
        <CalendarNextMonth Width="19px" />
        <CalendarNextYear Width="23px" />
        <CalendarFastNavPrevYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNPrevYear.png" />
        <CalendarFastNavNextYear Height="19px" Url="~/App_Themes/Aqua/Editors/edtCalendarFNNextYear.png" />
        <DropDownEditDropDown Height="7px" Url="~/App_Themes/Aqua/Editors/edtDropDown.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtDropDownDisabled.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtDropDownHottracked.png" />
        <SpinEditIncrement Height="6px" Url="~/App_Themes/Aqua/Editors/edtSpinEditIncrementImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditIncrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditIncrementHottrackedImage.png" />
        <SpinEditDecrement Height="7px" Url="~/App_Themes/Aqua/Editors/edtSpinEditDecrementImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditDecrementDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditDecrementHottrackedImage.png" />
        <SpinEditLargeIncrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeIncHottrackedImage.png" />
        <SpinEditLargeDecrement Height="9px" Url="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecImage.png"
          UrlDisabled="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecDisabledImage.png" UrlHottracked="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png"
          UrlPressed="~/App_Themes/Aqua/Editors/edtSpinEditLargeDecHottrackedImage.png" />
      </ImagesEditors>
      <ClientSideEvents EndCallback="function (s,e){ongvProductGroup_EndCallback(s,e);}" />
      <Columns>
        <dxwgv:GridViewDataTextColumn VisibleIndex="0" Width="40px">
          <DataItemTemplate>
            <img src="../Images/delete.png" onclick="onDelete('<%#Eval("Id") %>')" style="cursor: pointer"
              alt="" />
            <img src="../Images/edit.png" onclick="onEdit('<%#Eval("Id") %>','<%#Eval("Name") %>','<%#Eval("IsInventory") %>')"
              style="cursor: pointer;" alt="" />
          </DataItemTemplate>
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataTextColumn FieldName="Name" VisibleIndex="1" Caption="Tên">
          <HeaderStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataTextColumn>
        <dxwgv:GridViewDataCheckColumn FieldName="IsInventory" VisibleIndex="1" Caption="Quản lý tồn kho">
          <HeaderStyle HorizontalAlign="Center" />
        </dxwgv:GridViewDataCheckColumn>
      </Columns>
    </dxwgv:ASPxGridView>
  </div>
  <div style="padding-top: 5px;">
    <dxe:ASPxButton ID="btnAdd" runat="server" Text="Thêm mới" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
      CssPostfix="Aqua" AutoPostBack="False">
      <Image Url="../Images/add.png" />
      <ClientSideEvents Click="function(s, e) {
	onAdd();e.processOnServer = false;}" />
    </dxe:ASPxButton>
  </div>
  <div>
    <dxpc:ASPxPopupControl ID="pcAddProductGroup" ClientInstanceName="pcAddProductGroup"
      runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
      ImageFolder="~/App_Themes/Aqua/{0}/" Width="320px" PopupHorizontalAlign="WindowCenter"
      PopupVerticalAlign="WindowCenter" HeaderText="Danh mục hàng hóa" CloseAction="CloseButton"
      Modal="True">
      <ContentStyle VerticalAlign="Top">
      </ContentStyle>
      <SizeGripImage Height="12px" Width="12px" />
      <SizeGripImage Height="12px" Width="12px"></SizeGripImage>
      <ContentCollection>
        <dxpc:PopupControlContentControl>
          <div>
            <dxe:ASPxLabel ID="lblErrorMessage" ClientInstanceName="lblErrorMessage" runat="server"
              Font-Bold="True" ForeColor="#FF3300">
            </dxe:ASPxLabel>
          </div>
          <table>
            <tr>
              <td style="width: 80px;">
                <asp:Label ID="lblCountryName" runat="server" Text="Tên nhóm"></asp:Label>
                :
              </td>
              <td>
                <dxe:ASPxTextBox ID="txtProductGroupName" ClientInstanceName="txtProductGroupName"
                  runat="server" Width="170px" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua">
                  <ValidationSettings>
                    <ErrorImage Height="14px" Url="~/App_Themes/Soft Orange/Editors/edtError.png"></ErrorImage>
                    <ErrorImage Height="14px" Url="~/App_Themes/Aqua/Editors/edtError.png" />
                    <ErrorFrameStyle ImageSpacing="4px">
                      <ErrorTextPaddings PaddingLeft="4px"></ErrorTextPaddings>
                      <ErrorTextPaddings PaddingLeft="4px" />
                    </ErrorFrameStyle>
                  </ValidationSettings>
                </dxe:ASPxTextBox>
              </td>
            </tr>
            <tr>
              <td style="width: 100px;">
              </td>
              <td>
                <dxe:ASPxCheckBox ID="cbxInventory" Checked="true" ClientInstanceName="cbxInventory"
                  Text="Quản lý tồn kho" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                  CssPostfix="Aqua" TextSpacing="2px">
                </dxe:ASPxCheckBox>
              </td>
            </tr>
            <tr>
              <td>
              </td>
              <td style="padding-top: 4px;">
                <div style="float: left;">
                  <dxe:ASPxButton ID="btnSave" runat="server" Text="Lưu" AutoPostBack="False" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                    CssPostfix="Aqua">
                    <Image Url="../Images/save.png" />
                    <ClientSideEvents Click="function(s, e) {
	onSave();
}" />
                  </dxe:ASPxButton>
                </div>
                <div style="float: left; padding-left: 3px;">
                  <dxe:ASPxButton ID="btnCancel" runat="server" Text="Đóng" AutoPostBack="False" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                    CssPostfix="Aqua">
                    <ClientSideEvents Click="function(s, e) {
	onCancel(); e.processOnServer = false;
}"></ClientSideEvents>
                    <Image Url="" />
                    <ClientSideEvents Click="function(s, e) {
	onCancel(); e.processOnServer = false;
}" />
                  </dxe:ASPxButton>
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <asp:HiddenField ID="hfProductGroupId" runat="server" />
              </td>
            </tr>
          </table>
        </dxpc:PopupControlContentControl>
      </ContentCollection>
      <CloseButtonImage Height="16px" Width="18px" />
      <CloseButtonImage Height="18px" Width="18px"></CloseButtonImage>
      <HeaderStyle Font-Bold="True" ForeColor="#59A1EF" />
    </dxpc:ASPxPopupControl>
  </div>

  <script type="text/javascript" language="javascript">

    function onAdd() {
      ResetValue();
      pcAddProductGroup.Show();
    }
    function ResetValue() {
      txtProductGroupName.SetText('');
      document.getElementById('<%=hfProductGroupId.ClientID %>').value = '';
      lblErrorMessage.SetText('');
    }
    function onSave() {
      if (validateInput()) {
        gvProductGroup.PerformCallback('Save');
      }
    }
    function onCancel() {
      pcAddProductGroup.Hide();
    }
    function onDelete(countryId) {
      if (confirm('Bạn có chắc là muốn xóa?')) gvProductGroup.PerformCallback('Delete|' + countryId);
    }
    function onEdit(id, name,isInventory) {
      ResetValue();
      txtProductGroupName.SetText(name);
      document.getElementById('<%=hfProductGroupId.ClientID %>').value = id;
      if (isInventory == "True") {
        cbxInventory.SetChecked(true);
      }
      else {
        cbxInventory.SetChecked(false);
      }
      pcAddProductGroup.Show();

    }
    function validateInput() {
      var error = '';
      if (txtProductGroupName.GetText() == '')
        error += '<BR> + Tên nhóm hàng hóa không được bỏ trống';
      if (error != '') {
        lblErrorMessage.SetText(error);
        return false;
      }
      return true;
    }
    function ongvProductGroup_EndCallback(s, e) {
      var error = gvProductGroup.cpInnerError.split('|');
      if (error[0] == 'Save') {
        if (error[1] != '')
          lblErrorMessage.SetText(error[1]);
        else {
          pcAddProductGroup.Hide();
          alert('Cập nhật dữ liệu thành công');
        }
      }
      if (error[0] == 'Delete') {
        if (error[1] != '')
          alert(error[1]);
      }
    }

  </script>

</asp:Content>
